<%@page import="org.lxy.domain.RecycleGoodsEntity"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.lxy.domain.GoodsTypeEntity" %>
<%@ page import="org.lxy.utils.CoreUtils" %>
<%@ page import="org.lxy.domain.RecyclePointEntity" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>" />
<title>Edit</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="Stylesheet" href="/css/Form.css" />
<link href="/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery-1.9.1.js"></script>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-weight: bold;
}

.td_right {
	text-align: right;
}
</style>
</head>
<body>
	<form id="form1" action="/recyclegoods/edit" method="post" enctype="multipart/form-data">
		<div>
			<%
				RecycleGoodsEntity entity = (RecycleGoodsEntity) request.getAttribute("entitys");
				System.out.println(entity.getId());
			%>
			<table
				style="text-align: center; vertical-align: middle; line-height: 50px; margin-left: 20px; margin-top: 20px;">
				<input type="hidden" id="id" name="id" value="<%=entity.getId() == null ? 0 : entity.getId()%>" />
				<input type="hidden" value="回收点回收" name="huishoufangshi"/>
				<tr>
					<td class="td_right">名称：</td>
					<td><input type="text" id="mingcheng" name="mingcheng"
						class="search_txt"
						value="<%=entity.getName() == null ? "" : entity.getName()%>" />
					</td>
					<td class="td_right">类型：</td>
					<td>
					<select name="leixingid" class="search_txt" >
										<% List<GoodsTypeEntity> leixinglist = CoreUtils.goodsTypeService.list();
								
								for(GoodsTypeEntity leixing:leixinglist){
									%>
									<option value=<%=leixing.getId()%>><%=leixing.getName() %></option>
									<%
								}
								%></select>
						</td>
				</tr>
				<tr>
					<td class="td_right">回收点：</td>
					<td><select name="huishoudianid" class="search_txt" >
										<% 
										List<RecyclePointEntity> list = CoreUtils.recyclePointService.list();
										for (RecyclePointEntity item : list) {
									%>
									<option  value=<%=item.getId()%>><%=item.getName()%></option>
									<%
								}
								%></select></td>
				
					<td class="td_right">兑换积分：</td>
					<td><input type="text" id="duihuanjifen" name="duihuanjifen"
						class="search_txt" value="<%=entity.getChangePoints() == null ? 0 : entity.getChangePoints()%>" /></td>
				</tr>
				<tr>
					<td class="td_right">简介：</td>
					<td colspan="3">
					<textarea id="jieshao" name="jieshao" style="width:380px;height:100px;"
						class="search_txt"><%=entity.getInfo() == null ? "" : entity.getInfo()%></textarea>
					</td>
				</tr>
				<tr>
					<td class="td_right">图片：</td>
					<td colspan="3"><img id="img" style="width: 100%; height: 100px;"
						src="<%=entity.getImg()%>" onclick="upload()" /> <input
						type="file" name="tupian" id="PicLoad" style="display: none;"
						onchange="change(this)">
						</td>
				</tr>
				
				
				<tr>
					<td colspan="2"><input type="submit" id="btnOK" value="保存"
						class="btn_css submitbg" /> <input type="button" id="btnCZ"
						value="关闭" onclick="window.parent.closedialog();"
						class="btn_css reserbg" style="margin-left: 20px;" /></td>
				</tr>
			</table>
		</div>
	</form>
<script type="text/javascript">
	function upload() {

		$("#PicLoad").click();
	}
	function change(file) {
		// var prevDiv = document.getEleme+ntById('img');
		if (file.files && file.files[0]) {
			var reader = new FileReader();

			reader.onload = function(evt) {
				var filepath = evt.target.result;

				var extStart = filepath.lastIndexOf(".");
				var ext = filepath.substring(extStart, filepath.length)
						.toUpperCase();
				////BMP、JPG、JPEG、PNG、GIF
				//if (ext != ".PNG" && ext != ".BMP" && ext != ".JPG" && ext != ".JPEG" && ext != ".GIF") {
				//    //提示信息
				//    alert(" 图片格式不正确！");
				//    return false;
				//}
				$("#img").attr("src", evt.target.result);
			}
			reader.readAsDataURL(file.files[0]);
		} else {
			//prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
			alert($("#img").attr("src"));
			$("#img").attr("src", file.value);
			alert($("#img").attr("src"));
		}
	}
</script>
</body>
</html>
